<?php

class WeatherAction extends Action
{

    public function index()
    {
        $pinyin = $_GET['pinyin'];
        header("Content-type: text/html; charset=utf-8"); 
        $url = "http://www.google.com/ig/api?hl=zh-cn&weather=$pinyin";
        $xml = file_get_contents($url, FILE_USE_INCLUDE_PATH);
        echo   $xml;
    }
    
    
        public function getWeather($param) {
        $id = "101280101"; //此处是北京的城市ID，可以去weather.com.cn找到对应的weather city ID
        $url = "http://m.weather.com.cn/data/" . $id . ".html"; //接口URL
        $f = new SaeFetchurl(); //SAE fetchURL类
        $f->setMethod('get');
        $data = $f->fetch($url);

        $json = json_decode($data, TRUE); //解析json
        $data = $json["weatherinfo"];
        return $data['city'] . '今天气温' . $data['temp1'] . $data['weather1'] . $data['wind1'];
    }

}

?>